//
//  BaseTabBarController.m
//  ChhOrderApp
//
//  Created by chh on 16/8/11.
//  Copyright © 2016年 chh. All rights reserved.
//

#import "BaseTabBarController.h"
#import "OrderViewController.h"
#import "OrderListViewController.h"
#import "MainViewController.h"

@interface BaseTabBarController ()

@end

@implementation BaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addChildViewControllers];
    // Do any additional setup after loading the view.
}

-(void)addChildViewControllers{
    
    OrderViewController * orderVC= [[OrderViewController alloc]init];
    [self addChildViewController:orderVC WithTitle:@"点餐" image:@"info"];
    
    OrderListViewController * orderListVC = [[OrderListViewController alloc]init];
    [self addChildViewController:orderListVC WithTitle:@"订单" image:@"apply"];
    
    
    MainViewController * mainVC = [[MainViewController alloc]init];
    [self addChildViewController:mainVC WithTitle:@"我的" image:@"find"];
    
}

-(void)addChildViewController:(UIViewController *)childController WithTitle:(NSString *)title image:(NSString *)imageName{
    
    childController.tabBarItem.image = [UIImage imageNamed:imageName];
    
    childController.title = title;

    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:childController];
    
    UIImage *backButtonImage = [[UIImage imageNamed:@"backicon1@2x"] resizableImageWithCapInsets:UIEdgeInsetsMake(15, 15, 0, 0)];
    
    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    nav.navigationBar.barTintColor = backgroungColor;
    
    [self addChildViewController:nav];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
